<!--
 * @FilePath     : /layui/demo/layer/6313/iframe.html
 * @Description  :
 * @Date         : 2025-02-14 15:15
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-02-14 15:15
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>documentName</title>
</head>

<body class="childbody">
  <h4>iframe子页面</h4>
  <input type="text" value="">
  <script>
    function method() {
      console.log('执行子页面的方法');
    }

    //假设这是iframe页
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    console.log('当前 iframe 层的索引', index);

    setTimeout(function () {
      parent.layer.close(index); //再执行关闭
    }, 3000)
  </script>
</body>

</html>